﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Timers;
using System.IO;

namespace Srv3CodeTool
{
    public enum LOGTYPE
    {
        LOGTYPE_INFO,
        LOGTYPE_NOTICE,
        LOGTYPE_WARNING,
        LOGTYPE_ERROR,
    }
    class Log
    {
        public static void LogSave(char[] szMsg, LOGTYPE eType)
        {
            string strMsg = szMsg.ToString();
            LogSave(strMsg, eType);
        }

        public static void LogSave(string strMsg, LOGTYPE eType)    
        {
            string strLogTime = DateTime.Now.ToString();
            string strFilePrefix = ".\\Log";
            switch (eType)
            {
                case LOGTYPE.LOGTYPE_INFO:
                    {
                        strFilePrefix += "Info";
                    }
                    break;
                case LOGTYPE.LOGTYPE_NOTICE:
                    {
                        strFilePrefix += "Notice";
                    }
                    break;
                case LOGTYPE.LOGTYPE_WARNING:
                    {
                        strFilePrefix += "Warning";
                    }
                    break;
                case LOGTYPE.LOGTYPE_ERROR:
                    {
                        strFilePrefix += "Error";
                    }
                    break;
            }
            string strLogPath = ".\\LogError" + DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day + ".log";
            File.AppendAllText(strLogPath, strMsg+"\r\n\r\n");
        }
    }
}
